#include "TaskQueue.h"
#include "Thread.h"
#include <time.h>
#include <unistd.h>

using std::bind;

void push(TaskQueue& que)
{
	while(true)
	{
		::srand(time(NULL));
		::sleep(1);
		que.push(rand() % 100);
	}
}

void pop(TaskQueue& que)
{
	while(true)
	{
		::sleep(2);
		que.pop();
	}
}

int main(int argc, char* argv[])
{
	TaskQueue que(10);
	Thread producer(std::bind(push, std::ref(que)));
	Thread consumer(std::bind(pop, std::ref(que)));

	producer.start();
	consumer.start();

	producer.join();
	consumer.join();
    return 0;
}
